﻿using System;
using System.Drawing;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using StedySoft.SenseSDK;

namespace SenseTimeTracker.Reports
{
	public class ReportDisplayItem : CommonSenseControls.CommonSenseDisplayPanelItem
	{
		private Guid projectId = Guid.Empty;
		private string projectName = string.Empty;
		private TimeSpan projectTotalTime = TimeSpan.FromSeconds(0);

		public ReportDisplayItem()
		{
			Height = 50;
		}

		public Guid ProjectId
		{
			get { return projectId; }
			set { projectId = value; }
		}

		public string ProjectName
		{
			get { return projectName; }
			set { projectName = value; }
		}

		public TimeSpan ProjectTotalTime
		{
			get { return projectTotalTime; }
			set { projectTotalTime = value; }
		}

		#region ISenseListItem Members

		public override void OnRender(Graphics g)
		{
			using (Brush brush = new SolidBrush(Color.Black))
			using (Brush selecteionBrush = new SolidBrush(Color.Gray))
			using (Font primaryFont = new Font("Helvetica Neue OTS", 9f, FontStyle.Regular))
			{
				if (selected)
				{
					g.FillRectangle(selecteionBrush, ClientRectangle);
				}
				SizeF projectNameTextSize = g.MeasureString(projectName, primaryFont);
				g.DrawString(projectName, primaryFont, brush, ClientRectangle.Left + 8, ClientRectangle.Top + (ClientRectangle.Height - projectNameTextSize.Height) / 2);
				string projectTotalTimeFormatted = projectTotalTime.TotalHours.ToString("0.00");
				SizeF projectTotalTimeTextSize = g.MeasureString(projectTotalTimeFormatted, primaryFont);
				g.DrawString(projectTotalTimeFormatted, primaryFont, brush, ClientRectangle.Right - 8 - projectTotalTimeTextSize.Width, ClientRectangle.Top + (ClientRectangle.Height - projectTotalTimeTextSize.Height) / 2);
			}

			base.OnRender(g);
		}

		#endregion
	}
}
